<div>
	<div id="root-html" >

		<div class="titles fiex" style="height: 0;"></div>
		<div id="root-box" style="background: #eeeeee;"></div>
		
		 <script type="text/html" id="root-js">
	       
			
			<div class="shop_art" style="background: #fff;">
				<div class="table-top fiex">
					<a href="#!main-html" class="black"><svg class="g2" ><use xlink:href="#f_black"></use></svg></a>
					<div class="lang-xiala" id="lang-xiala"></div>					
					
					<div class="table">
						<span data-l="1050" class="f-30"></span><span class="f-50 mag-l-10">{{shop_table_name}}</span>
					</div>
					<img src="/images/null.gif"  data-src="{{shop_info.shop_thumb}}?x-oss-process=image/resize,m_fill,h_300,w_600" style="width: 100%; height: 3.8rem;" />
				</div>

				<div class="w">
					<div class="shop-head cf">
						<div class="icon fl mag-r-20"><img src="/images/null.gif" data-src="{{shop_info.shop_logo}}?x-oss-process=image/resize,m_fill,h_100,w_100" /></div>
						<div class="oh">
							<div class="f-40">{{shop_info.shop_name}}</div>
							<div class="mag-t-10 pad-t-10 aaa">
								<svg class="g2" style="fill: #aaa;"><use xlink:href="#f_gps"></use></svg>
								{{juli}}
							</div>
						</div>
					</div>
				</div>
			</div>
			
			<div class="pos-icon cf"  style="background: #fff;">
				<div class="fr fiex">
					<a href="tel:{{shop_info.mobile}}" class="fiex1"><svg class="g2" ><use xlink:href="#f_phone"></use></svg></a>
				</div>
				<div class="oh fiex pad-l-20">
					
						<div class="fiex1 "><a href="#!map-html?shop_name={{shop_info.shop_name}}&gps={{shop_info.position}}"  >
							<img src="/images/null.gif" data-src="/images/ditu.png" />
							
						</a></div>
						<div class="fiex8"><p>
								<a href="#!map-html?shop_name={{shop_info.shop_name}}&gps={{shop_info.position}}"  > 
									 {{shop_info.shop_address}}
								</a></p>
						</div>	
					
				</div>
			</div>
		
					
			<div class="root-bon cf fiex"  style="background: #fff;">
					<div class="bon bon1 fiex1">
						<a href="#!select-html?cookbook={{cookbook_list[0].id}}" class="fiex">
							<div class="svg"><svg class="g2" ><use xlink:href="#f_diancai"></use></svg></div>
							<div class=" fiex  f-30"><em class="fiex1" data-l="1002"></em></div>
						</a>
					</div>
					<div class="bon bon2 fiex1">
						<a href="javascript:;" class="fiex {{if count==0}}null{{/if}}" id="yidian">
							<div class="svg"><svg class="g2" ><use xlink:href="#f_dingdan"></use></svg></div>
							<div class=" fiex  f-30"><em class="fiex1" data-l="1003"></em> </div>
							<span>{{count}}</span>
						</a>
					</div>
					<div class="bon bon3 fiex1">
						<a href="javascript:;" class="fiex" id="hujiao">
							<div class="svg"><svg class="g2" ><use xlink:href="#f_hujiao"></use></svg></div>
							<div class="fiex  f-30 p1"><em class="fiex1" data-l="1043"></em></div>
							<div class="fiex  f-30 p2" ><em class="fiex1">60s</em></div>
						</a>
					</div>
			</div>
			
			{{if point>0}}
				<div class="bankgray"></div>
				<div class=" pad-10 center fiex" style="background: #fff;">
					<div class="fiex1"><img style="width: 0.8rem; height: 0.8rem;" src="/images/null.gif" data-src="/images/m_03.png"></div>
					<div class="fiex2">
						<span data-l="1174" class="mag-t-10"></span>			
						<span class="red f-bold f-30" id="point">{{point}}</span>
					</div>
					<div class="fiex1" id="getpoint">
						<div class="get mag-t-20 mag-b-20 f-30">
							<a href="#!bind_phone-html" class="bon-red" style="padding: 0.1rem;" data-l="1175"></a>
						</div>
					</div>
				</div>
			{{/if}}
			
			<div class="bankgray"></div>
		
			<div class="root-card cf"  style="background: #fff;">
				<div class="item">
					<a href="#!coupon_art-html?id={{shop_id}}">
						<div class="w w1">
							<div class="tb">
								<img src="/images/null.gif" data-src="/images/m_07.png" >
								<span data-l="1157"></span>
							</div>
						</div>
					</a>
				</div>
				<div class="item">
					<a href="#!vipcard_art-html?id={{shop_id}}&member_card={{member_card_id}}&open_card={{shop_info.shop_member_card_open}}">
						<div class="w w2">
							<div class="tb">
								<img src="/images/null.gif" data-src="/images/m_05.png" >
								<span data-l="1156"></span>
							</div>
						</div>
					</a>
				</div>
			</div>
			
			
			
			<div class="main-gg cf" style="display: none;">
				<img src="/images/null.gif" class="gg" data-src="/images/g1.png?123" />
			</div>
			
			<div class="game-list pad-20">
        	<div class="game_weix" style="display: none;">
        		<img src="/images/null.gif" data-src="/images/g1.png" style="width: 100%; height: auto;"  />
        	</div>
        	<div class="game_app"  style="display: none;">
        		<a href="javascript:;" class="bk g1 mag-b-20">
        			<img src="/images/null.gif" data-src="/images/g2.png" style="width: 100%; height: auto;"  />
        		</a>
        		<a href="javascript:;" class="bk g2 mag-b-20">
        			<img src="/images/null.gif" data-src="/images/g3.png" style="width: 100%; height: auto;"  />
        		</a>
        	</div>
        </div>
			

			<div class="bank50"></div>
	    </script>
		<script type="text/html" id="lang-xial-js">			
			<span class="l">&nbsp;</span>
    		<svg class="g2"><use xlink:href="#f_xiala"></use></svg>
    		<div class="child">
    			{{each lan as v i}}        		
    			 <a href="javascript:;" class="a {{if v.value==set}}on{{/if}}" data-lan="{{v.value}}">{{v.title}}</a>
    			{{/each}}
    		</div>
		</script>
		<script type="text/html" id="menu-list">
			<div class="menu-cookbook" id="menu-cookbook">
				<div class="box">
					<div class="close">X</div>
					<div class="list">
						<div class="list-scroll">
							{{each cookbook_list as v i}}
								{{if v.is_sell !=1}}
									<a href="#!select-html?cookbook={{v.id}}" class="null" style="background-image: url({{oss}}/{{v.thumb}}?x-oss-process=image/resize,m_fill,h_600,w_280);">
										<span data-l="1148"></span><em>{{v.cookbook_name}}</em></a>
								{{else}}
									<a href="#!select-html?cookbook={{v.id}}" style="background-image: url({{oss}}/{{v.thumb}}?x-oss-process=image/resize,m_fill,h_600,w_280);">
										<em>{{v.cookbook_name}}</em>
									</a>
								{{/if}}	                      		 
	                        {{/each}}
						</div>					
					</div>
				</div>
			</div> 
		</script>
		
<script> 
	
	//开启websookid
	if(connect_b){
		connect();
	}
	delCookie("other");
	
		

    var defaultfun = function () {   
    	//alert(getCookie("yingsoft_home_member_id"))
        //加载店铺信息
        global_ajax(jsonpath + "get_shop_home",{}, function (e) {
            var ee = e;
			//设置定位
			if(getCookie("gps")=="null"){
				ee.result.juli=lange[1188];
			}else{
				mygps=getCookie("gps").split(",")			 		
		 		var sgps=ee.result.shop_info.position.split(","),
		 			km=getGreatCircleDistance(mygps[0], mygps[1], sgps[0],sgps[1]);		
		 			localStorage.setItem("shopgps",sgps);
		 			if(km>1000){
		 				km=toFixed2(Math.floor(km)/1000,1)+"Km"
		 			}else{
		 				km=Math.floor(km)+"m"
		 			}
		 			ee.result.juli=km;
			}
			
			ee.result.point=localStorage.getItem("point");//设置为登录用户积分
			ee.result.gps=getCookie("gps")
			ee.result.oss=oss;
			//console.log(ee.result)
			$("#root-box").html(template("root-js", ee.result));
			setlange_obj();
			
			selectLanguage(function(e){
				localStorage.removeItem("key1");
			 	defaultfun();//设置菜谱缓存
			})//语言选择下拉
			
			//是否微信
			console.log(isWeiXin())
	    	if(isWeiXin()){
	    		$(".game_weix").show();
	    	}else{
	    		$(".game_app").show();
	    	}
	    	$(".game-list .g1").on("click",function(){
        		window.location.href="http://api.foodie.vc/game/hmk/?from=app&r="+Math.random()
        	})
        	$(".game-list .g2").on("click",function(){
        		window.location.href="http://api.foodie.vc/game/cjmla/?from=app&r="+Math.random()
        	})
	    	
			
			
			$("img").each(function(){
				var $th=$(this),
					src=$(this).data("src");
				console.log($th.is(":visible"))
				if(src && $th.is(":visible")){
					$(this).attr("src",src+"?"+localStorage.getItem("setver"));					
				}				
			});
			
			
			localStorage.setItem("shop_language",JSON.stringify(ee.result.shop_info.shop_language_list))//设置店铺支持语言选项
			localStorage.setItem("pax",ee.result.pax)//设置当前点餐人数
			//设置多菜谱
			localStorage.setItem("cookbook_list",JSON.stringify(ee.result.cookbook_list))//设置可用菜谱
			if(ee.result.cookbook_list.length>1){
				
				
				$(".root-bon .bon1 a").attr("href","javascript:;")
				$(".root-bon .bon1 a").on("click",function(){
					$("#menu-cookbook").remove();
					$("#root-box").append(template("menu-list", ee.result));
					$("#menu-cookbook .list-scroll").css({"max-height":$(window).height()*0.8})
					$("#menu-cookbook .box").css("margin-top",0-$("#menu-cookbook .box").height()/2.4)
					setlange_obj();
					//关闭菜谱层
					$("#menu-cookbook .close , #menu-cookbook ").on("click",function(){
						$("#menu-cookbook").remove();
					})
				})
			}
			

	    	$("#languages").on("click",function(){
	    		$(".select-inp").select("open",function(){})
	    	})
			
			
			
           	//不是APP隐藏返回按钮
			if(getCookie("from")=="app"){
				$(".table-top .black").show()
			}else{
				$(".table-top .black").hide()
			}
			
			
           	
           	//点击呼叫
		    $("#hujiao").click(function () {
		        var $th = $(this);
		        if ($th.hasClass("open")) return false;
		        $th.addClass("open");
		        global_ajax(jsonpath + "put_call_waiter", '', function (e) {
		            var s1 = 60;
		            $.toast(lange["1044"], "text");
		            s2 = setInterval(function () {
		                s1--;
		                $th.find(".p2 em").text(s1+"s");
		                if (s1 == 0)
		                {
		                    $th.removeClass("open")
		                    clearInterval(s2);
		                }
		            },1000)
		        })
		    })
			//查看已点 #!order_see-html
			$("#yidian").click(function () {
				var $th = $(this);
		        if ($th.hasClass("null")) return false;
		        Q.go("order_see-html");
			})
			
			
			
			 global_ajax(jsonpath + "get_shop_ver", '', function (e) {
			 	if(localStorage.getItem("ver")!=e.result.ver){
			 		localStorage.removeItem("key1");			 		
			 		localStorage.setItem("ver",e.result.ver)
			 	}
			 	setmenu();
			 })
			
           	

			})
    }

//缓存菜品列表
	function  setmenu(){
		
		if(localStorage.getItem("key1")==null){
			var setlangua=getCookie("language")
			if(localStorage.getItem("shop_language").indexOf('"'+setlangua+'"')==-1) setlangua="en";
			$.ajax({
		        type: "get",
		        dataType: "json",
		        url: oss+"/shop_goods/"+ getCookie("shopid") +"_"+setlangua+".json",
		        cache: false,
		        success: function (e) {
		        	 //设置返回值
			               localStorage.setItem("key1", JSON.stringify(e))
			               var key2={},key3={},key4={},key5={};
			               $.each(e.result.list,function(i,v){
			               		if(v.id==1||v.id==2){}else{
			               			$.each(v.goods_list,function(ii,vv){               				
			               				key2[vv.id]=vv;		               				
			               			})               			
			               		}
			               });
			               $.each(e.result.spec_list,function(iii,vvv){
		       					key3[vvv.spec_id]=vvv;
		       				})
		       				$.each(e.result.taste_list,function(iii,vvv){
		       					key4[vvv.taste_id]=vvv;
		       				})
		       				$.each(e.result.garnish_list,function(iii,vvv){
		       					key5[vvv.garnish_id]=vvv;
		       				})
						  //设置菜品
						   localStorage.setItem("key2", JSON.stringify(key2))
						   localStorage.setItem("key3", JSON.stringify(key3))
						   localStorage.setItem("key4", JSON.stringify(key4))
						   localStorage.setItem("key5", JSON.stringify(key5))
						   caidan_json=key2;
						   guige1_json=key3;
						   kouwei1_json=key4;
						   peicai_json=key5;
		            
		        },
		        error: function () {		           
		            $.hideLoading();		        	
		            $.modal({
			          title: "tips",
			          text: "Loading error",
			          buttons: [
			            { text: "Refresh", onClick: function(){
			            	location.reload(true)  
			            } }
			          ]
			       });
		        }
		       })
		    }
        
	}
    
    //初始化加载
	defaultfun();
	
	//启动定位
	setmap1();
</script>
</div>
</div>